{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "70c15156",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: colorlog in /home/westwood/anaconda3/lib/python3.8/site-packages (6.6.0)\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "pip install colorlog"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "403b4770",
   "metadata": {},
   "outputs": [],
   "source": [
    "import logging\n",
    "import colorlog\n",
    "import importlib\n",
    "\n",
    "def basicConfig(formatter = \"%(levelname)-8s | %(message)s\", **kwargs):\n",
    "    importlib.reload(logging)\n",
    "    handler = colorlog.StreamHandler()\n",
    "    handler.setFormatter(colorlog.ColoredFormatter(f'%(log_color)s{formatter}%(reset)s'))\n",
    "    handler.setLevel(**kwargs)\n",
    "    logging.basicConfig(\n",
    "        handlers=[handler],\n",
    "        **kwargs,\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "0f669165",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[37mDEBUG    | A quirky message only developers care about\u001b[0m\n",
      "\u001b[32mINFO     | Curious users might want to know this\u001b[0m\n",
      "\u001b[33mWARNING  | Something is wrong and any user should be informed\u001b[0m\n",
      "\u001b[31mERROR    | Serious stuff, this is red for a reason\u001b[0m\n",
      "\u001b[1;31mCRITICAL | OH NO everything is on fire\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "basicConfig(level=\"DEBUG\")\n",
    "logging.debug(\"A quirky message only developers care about\")\n",
    "logging.info(\"Curious users might want to know this\")\n",
    "logging.warning(\"Something is wrong and any user should be informed\")\n",
    "logging.error(\"Serious stuff, this is red for a reason\")\n",
    "logging.critical(\"OH NO everything is on fire\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b11773de",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[33mWARNING  | Something is wrong and any user should be informed\u001b[0m\n",
      "\u001b[31mERROR    | Serious stuff, this is red for a reason\u001b[0m\n",
      "\u001b[1;31mCRITICAL | OH NO everything is on fire\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "basicConfig(level=\"WARNING\")\n",
    "logging.debug(\"A quirky message only developers care about\")\n",
    "logging.info(\"Curious users might want to know this\")\n",
    "logging.warning(\"Something is wrong and any user should be informed\")\n",
    "logging.error(\"Serious stuff, this is red for a reason\")\n",
    "logging.critical(\"OH NO everything is on fire\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
